package com.zhengshang.api.service.impl;

import com.zhengshang.api.domain.AppOilcard;
import com.zhengshang.api.mapper.AppOilcardMapper;
import com.zhengshang.api.service.IAppOilcardService;
import com.zhengshang.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 用户加油卡Service业务层处理
 * 
 * @author zhengshang
 * @date 2022-04-10
 */
@Service
public class AppOilcardServiceImpl implements IAppOilcardService
{
    @Autowired
    private AppOilcardMapper appOilcardMapper;

    /**
     * 查询用户加油卡
     * 
     * @param oilcardId 用户加油卡ID
     * @return 用户加油卡
     */
    @Override
    public AppOilcard selectAppOilcardById(Long oilcardId)
    {
        return appOilcardMapper.selectAppOilcardById(oilcardId);
    }

    /**
     * 查询用户加油卡列表
     * 
     * @param appOilcard 用户加油卡
     * @return 用户加油卡
     */
    @Override
    public List<AppOilcard> selectAppOilcardList(AppOilcard appOilcard)
    {
        return appOilcardMapper.selectAppOilcardList(appOilcard);
    }

    @Override
    public List<Map> queryAppOilcardList(AppOilcard appOilcard) {
        return appOilcardMapper.queryAppOilcardList(appOilcard);
    }

    /**
     * 新增用户加油卡
     * 
     * @param appOilcard 用户加油卡
     * @return 结果
     */
    @Override
    public int insertAppOilcard(AppOilcard appOilcard)
    {
        appOilcard.setCreateTime(DateUtils.getNowDate());
        return appOilcardMapper.insertAppOilcard(appOilcard);
    }

    /**
     * 修改用户加油卡
     * 
     * @param appOilcard 用户加油卡
     * @return 结果
     */
    @Override
    public int updateAppOilcard(AppOilcard appOilcard)
    {
        appOilcard.setUpdateTime(DateUtils.getNowDate());
        return appOilcardMapper.updateAppOilcard(appOilcard);
    }

    /**
     * 批量删除用户加油卡
     * 
     * @param oilcardIds 需要删除的用户加油卡ID
     * @return 结果
     */
    @Override
    public int deleteAppOilcardByIds(Long[] oilcardIds)
    {
        return appOilcardMapper.deleteAppOilcardByIds(oilcardIds);
    }

    /**
     * 删除用户加油卡信息
     * 
     * @param oilcardId 用户加油卡ID
     * @return 结果
     */
    @Override
    public int deleteAppOilcardById(Long oilcardId)
    {
        return appOilcardMapper.deleteAppOilcardById(oilcardId);
    }

    @Override
    public int changeDefault(Long userId, Integer isDefault) {
        return appOilcardMapper.changeDefault(userId,isDefault);
    }
}
